//Disjoint Set with path compress
//poj2524Ubiquitous Religions
#include <cstdio>
#include <cstring>

using namespace std;

const int MAXSIZE = 50010;

class UFset {
	public :
		UFset(int size = MAXSIZE);
		int find(int key) const;
		void unite(int a, int b);
		bool differ(int a, int b) const;
	private :
		int *array;
		int sz;
};
UFset::UFset(int size) {
	sz = size;
	array = new int [sz];
	for(int i = 0; i < sz; ++i)
		array[i] = i;
}
int UFset::find(int key) const {
	if (array[key] == key) return key;
	array[key] = find(array[key]);
	return array[key];
}
void UFset::unite(int a, int b) {
	int root1 = find(a);
	int root2 = find(b);
	if (root1 != root2) array[root2] = root1;
}
bool UFset::differ(int a, int b) const {
	return find(a) != find(b);
}

int main() {
	int n, m, kase = 0;
	bool hash[MAXSIZE];
	while (scanf("%d%d", &n, &m) != EOF && (n || m)) {
		UFset uf(n + 1);
		int a, b, ret = 0;
		for (int i = 0; i < m; ++ i) {
			scanf("%d%d", &a, &b);
			uf.unite(a, b);
		}
		memset(hash, 0, sizeof(hash));
		for (int i = 1; i <= n; ++ i)
			hash[uf.find(i)] = true;
		for (int i = 1; i <= n; ++ i)
			if (hash[i]) ret ++;
		printf("Case %d: %d\n", ++ kase, ret);
	}
	return 0;
}
